<?LassoScript

	'<div id="patient-searchForm">';
			rows: -InlineName=(Var: ($rewAction + '_Table'));
					If: (Loop_Count) == 1;
							$showing += '<strong>Showing ' shown_first ' &mdash; ' shown_last ' of ' found_count ' results</strong>';
					/if;
			/rows;
			'<div id="showingRecords">' $showing '</div>';
	'<form 
		action="' (response_path)'" 
		method="post">
			<input 
				type="hidden" 
				name="searchType" 
				value="new" 
				class="ahem" 
				/>
			<input 
				type="text" 
				id="keyword" 
				name="keyword" 
				value="' (var('keyword') ? var('keyword') | 'Search') '" onclick="if (this.value == \'Search\') this.value = \'\';" onblur="if (this.value == \'\') this.value = \'Search\';" 
				size="20" 
				maxlength="100" 
				/>
			<input 
				type="submit" 
				value="Filter" 
				/>
			<input 
				type="button" 
				name="-Nothing" 
				value="Reset Search" 
				onclick="javascript:window.location=(\'' + $rewAction_ResetPage_pathTo + '\?exit=' + (response_path) + '\')"
				 />
			</form>';
			rows: -InlineName=(Var: ($rewAction + '_Table'));
					If: (Loop_Count) == 1;


/*]<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
this is simliar to the default records nav, but has chagnes requested 
specifically for this project.
------------------------------------------------------------------ Chris Corwin ---->
[*/


//  Found Set Navigation
//  
//  This routine is used to create "Clickable Page Links" similar to those seen on
//  Google's search results pages. The idea is that the user is presented with
//  hyperlink numbers that represent pages with records, e.g. a found set of 200
//  records may be spread out over 20 pages with 10 records on each page.
//  
//  Written by Pier Kuipers
//  Dublin, Ireland 
//  April 2003
//  
//  .............................................................................

//  The only required variable is called "maxpages" and refers to the
//  maximum number of clickable page links displayed on the results page.
//	Declared on siteconfig.inc.	
//	
//  We start by analysing the given SkipRecords value to establish how many page
//  links should be displayed, and from which page we start numbering in case the
//  user jumped to the next set of pages.
//[



		var:'skip'=((Integer:(SkipRecords_Value)) + (Integer:(MaxRecords_Value)));
		var:'pages'=(Math_Ceil: ((decimal:($foundCount)) / (decimal: (MaxRecords_Value))));
		If:$pages>=$maxpages;
			var:'pages'=$maxpages;
		/If;
		var:'page_calc'=(integer((Math_Floor:($skip / (decimal:((MaxRecords_Value) * $maxpages)))) * $maxpages) + 1);
		If:(math_mod:$skip, ((MaxRecords_Value) * $maxpages))==0;
			If:$skip==((MaxRecords_Value) * $maxpages);
				var:'page_no'=1;
				var:'skip2'=0;
			else;
				var:'page_no'=integer($page_calc - $maxpages);
				var:'skip2'=(((Math_Floor:($skip / (decimal:((MaxRecords_Value) * $maxpages)))) * ((MaxRecords_Value) * $maxpages)) - ((MaxRecords_Value) * $maxpages));
			/If;
		Else;
			var:'page_no'=$page_calc;
			var:'skip2'=((Math_Floor:($skip / (decimal:((MaxRecords_Value) * $maxpages)))) * ((MaxRecords_Value) * $maxpages));
		/If;

// 		'<p>Showing ' + Shown_Count + ' records (' + Shown_First + ' &#8211; ' + Shown_Last + ') of ' + $foundCount + ' records found (' + MaxRecords_Value + ' max)&nbsp;</p>';
// 		'<p>Page ' + ((Shown_First / MaxRecords_Value) + 1) + ' of ' + ((((MaxRecords_Value) * (Math_Floor:(decimal:($foundCount)) / (decimal:(MaxRecords_Value)))) / MaxRecords_Value) + 1) +  '</p>';
// 		'<p>' + ((((MaxRecords_Value) * (Math_Floor:(decimal:($foundCount)) / (decimal:(MaxRecords_Value)))) / MaxRecords_Value) + 1) + '</p>';

// 		Var: 'showAsSkip' = ('Page ' + ((Shown_First / MaxRecords_Value) + 1) + ' of ' + ((((MaxRecords_Value) * (Math_Floor:(decimal:($foundCount)) / (decimal:(MaxRecords_Value)))) / MaxRecords_Value) + 1));
		Var: 'showAsSkip' = ((Shown_First / MaxRecords_Value) + 1);


//]
//  The first possible hyperlink will lead the user to the very first record from
//  anywhere in the found set.
//[

		If:(Shown_First)>=(MaxRecords_Value);
				'<span class="ahem">';
						'&nbsp;';
				'</span>';
				'<a 
					href="?TXT-SkipRecords=0" ';
					'title="Go to the first record." ';
					'class="first-page" ';
					'>';
						'&lt;&lt;';
				'</a>';
				'<span class="ahem">';
						'&nbsp;';
				'</span>';
		else;
		/if;
	
//]
//  The second hyperlink, if applicable, is there to jump to the previous set of 
//  results pages
//[

		If:$skip2>0;
/* 				'<span class="ahem">'; */
/* 						'&nbsp;'; */
/* 				'</span>'; */
/* 				'<a  */
/* 					href="?TXT-SkipRecords=' + ((($page_no - 1) * (maxrecords_value)) - (maxrecords_value)) + '" '; */
/* 					'class="group" '; */
/* 					'title="Go to the previous group." '; */
/* 					'>'; */
/* 						'&lt;&nbsp;Group'; */
/* 				'</a>'; */
/* 				'<span class="ahem">'; */
/* 						'&nbsp;'; */
/* 				'</span>'; */
		Else;
		/If;
	
//]
//  The third hyperlink, if applicable, simply brings the user to the previous 
//  results page
//[

		If:($skip > (MaxRecords_Value));
			'<span class="ahem">';
					'&nbsp;';
			'</span>';
			'<a ';
				'href="?TXT-SkipRecords=' + ($skip - ((MaxRecords_Value) * 2)) + '" ';
				'class="previous-page" ';
				'title="Go to the previous page." ';
				'>';
					'Previous';
			'</a>';
			'<span class="ahem">';
					'&nbsp;';
			'</span>';
		Else;
		/If;
			
//]
//  Finally getting to the all important hyperlinks to individual pages.
//  This part of the routine uses the maxpages variable to define the
//  maximum number of page links to be displayed, which means that the user
//  may have clicked to the next or previous set of pages (see second
//  hyperlink description above). If the maximum is set to 10 with a
//  Maxrecords value of 10 and a found set of 200 records, the "pages" and
//  "page_no" variables take care of the correct page numbering, e.g 11-20
//  for the second "set".
//[

		loop:$pages;
			If:(((skiprecords_value) / (maxrecords_value)) + 1)==$page_no;
				'<span class="ahem">';
						'&nbsp;';
				'</span>';
				'<span class="page-hilite">';
						$showAsSkip;
				'</span>';
/* 				'<span class="hilite">'; */
/* 						'<form action="' + (Response_Path) + '" style="display: inline;"  title="Jump to&hellip;" >'; */
/* 							'&nbsp;Skip:&nbsp;'; */
/* 							'<input  */
/* 								type="text"  */
/* 								name="TXT-SkipRecords"  */
/* 								onclick="if (this.value == \'' + (Shown_Last) + '\') this.value = \'\';"  */
/* 								onblur="if (this.value == \'\') this.value = \'' + (Shown_Last) + '\';"  */
/* 								id="JumpToImage" */
/* 								value="' + (Shown_Last) + '" />'; */
/* 						'</form>'; */
/* 				'</span>'; */
				'<span class="ahem">';
						'&nbsp;';
				'</span>';
				
			else;
				'<a ';
					'href="?TXT-SkipRecords=' + $skip2 + '" ';
					'title="Go to page number ' + $page_no + '." ';
					'class="other-page" '
					'>';
						'<span class="ahem">';
								'&nbsp;';
						'</span>';
						$page_no;
						'<span class="ahem">';
								'&nbsp;';
						'</span>';
				'</a>';
			/If;
			var:'page_no'=($page_no + 1),
				'skip2'=($skip2 + (MaxRecords_Value));
			If: $skip2 >= ($foundCount);
				Loop_Abort;
			/If;
		/loop;
	
//]
//  The equivalent of the third hyperlink, pointing to the next results page.
//[

		If:($foundCount>$skip);
			'<span class="ahem">';
					'&nbsp;';
			'</span>';
			'<a ';
				'href="?TXT-SkipRecords=' + $skip + '" ';
				'title="Go to the next page." ';
				'class="next-page" ';
				'>';
					'Next';
			'</a>';
			'<span class="ahem">';
					'&nbsp;';
			'</span>';
		/If;
//]
//  The equivalent of the second hyperlink, jumping to the next set of pages.
//[

/* 		If:$skip2<($foundCount); */
/* 			'<span class="ahem">'; */
/* 					'&nbsp;'; */
/* 			'</span>'; */
/* 			'<a '; */
/* 				'href="?TXT-SkipRecords=' + $skip2 + '" '; */
/* 				'title="Go to the next group." '; */
/* 				'class="group"'; */
/* 				'>'; */
/* 					'Group&nbsp;&gt;'; */
/* 			'</a>'; */
/* 			'<span class="ahem">'; */
/* 					'&nbsp;'; */
/* 			'</span>'; */
/* 		Else; */
/* 		/If; */
			
//]
//  The last hyperlink requires some additional calculations, courtesy of
//  Michael Collins, to bring the user to the page displaying the very last
//  record.
//[

		If:(($foundCount) % (MaxRecords_Value))==0;
			Var:'Skip'=(($foundCount) - (MaxRecords_Value));
		else;
			Var:'Skip'=((MaxRecords_Value) * (Math_Floor:(decimal:($foundCount)) / (decimal:(MaxRecords_Value))));
		/If;
		If:(($Skip) <= ($foundCount))&&((Shown_Last)!=($foundCount));
			'<span class="ahem">';
					'&nbsp;';
			'</span>';
			'<a ';
				'href="?TXT-SkipRecords=' + $Skip + '" ';
				'title="Go to the last page." ';
				'class="last-page"';
				'>';
					'&gt;&gt;';
			'</a>';
			'<span class="ahem">';
					'&nbsp;';
			'</span>';
		else;
		/if;



					/if;
			/rows;
	'</div>';



?>